home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / greps.zip / README~1.SUN < prev    next >
Text File  |  1993-09-17  |  3KB  |  100 lines

  1. [ N.B. This bug strikes on a Sun 3 running SunOS 4 with the cc -O4 option
  2.   as well as on the sparc.  -Mike ]
  3.  
  4. Date:    Fri, 24 Feb 89 15:36:40 -0600
  5. To:      mike@wheaties.ai.mit.edu
  6. From:    Dave Cohrs <dave@cs.wisc.edu>
  7. Subject: bug + fix in gnu grep 1.2 (from prep.ai.mit.edu)
  8.  
  9. I tried installing the GNU grep 1.2 on a Sun4 running 4.0.1 and
  10. "Spencer test #36" failed.  After some experimenting, I found and
  11. fixed the bug.  Well, actually, the bug in the the C compiler, but
  12. I managed a workaround.
  13.  
  14. Description:
  15.  
  16. The Sun4 4.0.1 C compiler with -O doesn't generate the correct for
  17. statements of the form
  18.     if("string")
  19.         x;
  20.     else
  21.         y;
  22. To be exact, "y;" gets executed, while "x;" should.  This causes the
  23. #define FETCH() to fail for test #36.
  24.  
  25. Fix:
  26.  
  27. In an #ifdef sparc in dfa.c, I made two versions of FETCH, FETCH0() and
  28. the regular FETCH().  The former takes only one argument, the latter
  29. expects its 2nd argument to contain a non-nil string.  This removes
  30. the need to test the constant strings, and the compiler bug isn't
  31. exercised.  I then changed the one instance of FETCH() with a nil
  32. second argument to be FETCH0() instead.
  33.  
  34. dave cohrs
  35.  
  36. ===================================================================
  37. RCS file: RCS/dfa.c,v
  38. retrieving revision 1.1
  39. diff -c -r1.1 dfa.c
  40. *** /tmp/,RCSt1a05930    Fri Feb 24 15:32:33 1989
  41. --- dfa.c    Fri Feb 24 15:23:34 1989
  42. ***************
  43. *** 285,293 ****
  44. --- 285,315 ----
  45.                      is turned off). */
  46.   
  47.   /* Note that characters become unsigned here. */
  48. + #ifdef sparc
  49. + /*
  50. +  * Sun4 4.0.1 C compiler can't compare constant strings correctly.
  51. +  * e.g. if("test") { x; } else { y; }
  52. +  * the compiler will not generate code to execute { x; }, but
  53. +  * executes { y; } instead.
  54. +  */
  55. + #define FETCH0(c)                 \
  56. +   {                         \
  57. +     if (! lexleft)                 \
  58. +       return _END;                 \
  59. +     (c) = (unsigned char) *lexptr++;  \
  60. +     --lexleft;                     \
  61. +   }
  62.   #define FETCH(c, eoferr)             \
  63.     {                         \
  64.       if (! lexleft)                 \
  65. +       regerror(eoferr);            \
  66. +     (c) = (unsigned char) *lexptr++;  \
  67. +     --lexleft;                     \
  68. +   }
  69. + #else
  70. + #define FETCH(c, eoferr)             \
  71. +   {                         \
  72. +     if (! lexleft)                 \
  73.         if (eoferr)                 \
  74.       regerror(eoferr);            \
  75.         else                     \
  76. ***************
  77. *** 295,300 ****
  78. --- 317,323 ----
  79.       (c) = (unsigned char) *lexptr++;  \
  80.       --lexleft;                     \
  81.     }
  82. + #endif sparc
  83.   
  84.   static _token
  85.   lex()
  86. ***************
  87. *** 303,309 ****
  88. --- 326,336 ----
  89.     int invert;
  90.     _charset cset;
  91.   
  92. + #ifdef sparc
  93. +   FETCH0(c);
  94. + #else
  95.     FETCH(c, (char *) 0);
  96. + #endif sparc
  97.     switch (c)
  98.       {
  99.       case '^':
  100.